package com.smt.modules.bus.service.impl;

import com.smt.modules.bus.entity.StreamEntity;
import com.smt.modules.bus.vo.EmailStreamVo;
import com.smt.modules.bus.vo.StreamVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.smt.common.utils.PageUtils;
import com.smt.common.utils.Query;

import com.smt.modules.bus.dao.EmailStreamDao;
import com.smt.modules.bus.entity.EmailStreamEntity;
import com.smt.modules.bus.service.EmailStreamService;


@Slf4j
@Service("emailStreamService")
public class EmailStreamServiceImpl extends ServiceImpl<EmailStreamDao, EmailStreamEntity> implements EmailStreamService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<EmailStreamEntity> page = this.selectPage(
                new Query<EmailStreamEntity>(params).getPage(),
                new EntityWrapper<EmailStreamEntity>()
        );

        return new PageUtils(page);
    }
    @Override
    public EmailStreamVo selectOneByMobileNumber(String emailNumber) {
        EmailStreamEntity emailStreamEntity = selectOne(new EntityWrapper().eq("emails", emailNumber).orderBy("create_time", false));
        log.info("根据手机号查出的最近的邮箱详情:{}",emailStreamEntity);
        return emailStreamEntity == null ? null : emailStreamEntity.copyPropertiesTo(new EmailStreamVo());
    }
}
